package com.geostar.constructionland.analyse.factory;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.geostar.constructionland.analyse.config.SpringUtil;
import com.geostar.constructionland.analyse.entity.model.AnalyseModel;
import com.geostar.constructionland.analyse.mapper.AdjustVersionMapper;
import com.geostar.constructionland.analyse.service.adjust.DlMmAdjust;
import com.geostar.constructionland.analyse.service.adjust.IAdjust;
import com.geostar.constructionland.analyse.service.adjust.TzhDlGdAdjust;
import com.geostar.constructionland.common.entity.response.AdjustAgrVersion;
import com.geostar.constructionland.common.entity.response.model.AdjustModel;
import com.geostar.constructionland.common.global.AnalyseType;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.lang.reflect.Constructor;
import java.util.List;

/**
 * @author yelll
 * @since 2020-5-25 17:11
 * 平差算法构建工厂
 **/
@Component
public class AdjustAgrFactory {
    /**
     * 获取
     * @param adjustAgrVersion
     * @return
     */
    public static IAdjust getAdjustAgr(AdjustAgrVersion adjustAgrVersion, AdjustModel adjustModel){
        IAdjust iAdjust = null;
        try{
            Class<?> classAdjust = Class.forName(adjustAgrVersion.getAdjustClass());
            iAdjust =(IAdjust) classAdjust.newInstance();
        }catch (Exception e){
            e.printStackTrace();
        }
        return iAdjust;
    }

    @Autowired
    AdjustVersionMapper adjustVersionMapper;

    /**
     * @param fxlx 分析类型
     * @return
     */
    public IAdjust getAdjustAgrByAnalyseModel(String fxlx) throws Exception{
        /**获取adjustmodel*/
        if(AnalyseType.TZHDLGDFX.getCode().equals(fxlx)){
            /**地类分析*/
            return SpringUtil.getBean(TzhDlGdAdjust.class);
        }else if(AnalyseType.DLMJJFX.getCode().equals(fxlx)){
            return SpringUtil.getBean(DlMmAdjust.class);
        }
        return null;
    }

}
